function checkIntegerInput( hObject, min, max, defaultValue )
%Checks integer input in edit box.
user_entry = str2double(get(hObject,'string'));
if isnan(user_entry)
  errordlg('You must enter a numeric value','Bad Input','modal')
  uicontrol(hObject)
	return
end
fixed_val = fix(user_entry);
if fixed_val < min || fixed_val > max
    error_str = sprintf('The value must be from %d to %d', min, max);
    errordlg(error_str,'Bad Input','modal');
    set(hObject, 'string', defaultValue);
    uicontrol(hObject)
    return
end
set(hObject, 'string', fixed_val);
end

